/*
	Write a program that accepts a base ten (non-fractional) number at the command line and outputs the binary representation of that number
*/
#include <iostream>
#include <stdlib.h>
#include <string>


using namespace std;

int main( int argc, char* argv[] ){

	int dec2conv = atoi(argv[1]);
	int current = dec2conv;
	div_t divresult;

	char omg[] = "01";

	string binary;
	cout << binary << endl;
	do {

		divresult = div(current,2);

		binary.append((omg+divresult.rem));

		cout << current << "\t" << divresult.rem << "\t" << divresult.quot << "\t" << binary << endl;

		current = divresult.quot;

	}while (divresult.quot > 1);

	cout << binary << endl;

	for (std::string::reverse_iterator rit=binary.rbegin(); rit<binary.rend(); ++rit)
    std::cout << *rit;

	cout << endl;

return 0;
}
